module vga_display #(
	parameter	H_DISP	= 10'd640,		    //分辨率(行)
	parameter	V_DISP	= 10'd480		    //分辨率(列)
)
(
	input					vga_clk,		//VGA驱动时钟
	input					sys_rst_n,		//复位信号
	
	input			[12:0]	pixel_xpos,		//像素点横坐标
	input			[12:0]	pixel_ypos,		//像素点纵坐标
	output      reg	[11:0]	pixel_data		//像素点数据
);

	localparam		BLACK		=12'h000;
	localparam		BLUE		=12'h00F;
	localparam		GREEN		=12'h0F0;
	localparam		CYAN		=12'h0FF;
	localparam		RED		=12'hF00;
	localparam		PEATH		=12'hF0F;
	localparam		YELLOW	=12'hFF0;
	localparam		WHITE		=12'hFFF;

	localparam		H_DIVIDE_8 = H_DISP / 8;

	//根据当前像素点坐标指定当前像素点颜色数据，在屏幕上显示彩条
	always @ (posedge vga_clk or negedge sys_rst_n) begin
		if(!sys_rst_n) pixel_data <= 12'd0;
		else begin
			if(pixel_xpos >= 0 && pixel_xpos < H_DIVIDE_8) pixel_data <= YELLOW;
			else if(pixel_xpos >= H_DIVIDE_8 && pixel_xpos < H_DIVIDE_8 * 2) pixel_data <= BLACK;
			else if(pixel_xpos >= H_DIVIDE_8 * 2 && pixel_xpos < H_DIVIDE_8 * 3) pixel_data <= BLUE;
			else if(pixel_xpos >= H_DIVIDE_8 * 3 && pixel_xpos < H_DIVIDE_8 * 4) pixel_data <= GREEN;
			else if(pixel_xpos >= H_DIVIDE_8 * 4 && pixel_xpos < H_DIVIDE_8 * 5) pixel_data <= CYAN;
			else if(pixel_xpos >= H_DIVIDE_8 * 5 && pixel_xpos < H_DIVIDE_8 * 6) pixel_data <= RED;
			else if(pixel_xpos >= H_DIVIDE_8 * 6 && pixel_xpos < H_DIVIDE_8 * 7) pixel_data <= PEATH;
			else pixel_data <= WHITE;
		end
	end

endmodule 